<?php
class WizardSteps{
	private static $instance;
	private $wizardSteps = array("Work Selection" => "imptwiz1_worklist.php",
				"Data Upload" => "imptwiz2_upload.php",
				"Verify Players" => "imptwiz3_players.php",
				"Verify Courses" => "imptwiz4_courses.php",
				"Confirmation" => "imptwiz5_final_conf.php",
				"Completed" => "imptwiz6_completed.php");	
	private $currentStep = 1;
	
	private function __construct(){
	}
	
	public static function getInstance(){
		if(!self::$instance){
			self::$instance = new WizardSteps();
		}
		return self::$instance;
	}
	public function getList(){
		return $this->wizardSteps;
	}
	
	public function printTitle(){
		return sprintf("Step %s of %s. %s",$this->currentStep,count($this->wizardSteps),$this->getCurrentElement(true));
	}
	
	public function getCurrentFile(){
		return $this->getCurrentElement(false);
	}
	
	private function getCurrentElement($getTitle){
		$i = 0;
		foreach($this->wizardSteps as $key=>$val){
			if($this->currentStep < 1 && $this->currentStep > count($this->wizardSteps)){
				throw new Exception(sprintf("variable has to be equal and greater than 1 and equal less than %s",count($this->wizardSteps)));
			}
			$i++;
			if($this->currentStep == $i){
				return ($getTitle)?$key:$val;
			}
		}
	}
	
	public function setCurrentStep($i){
		if($i < 1 && $i > count($this->wizardSteps)){
			throw new Exception(sprintf("variable has to be equal and greater than 1 and equal less than %s",count($this->wizardSteps)));
		}
		$this->currentStep = $i;
	}
	
	public function getCurrentStep(){
		return $this->currentStep;
	}
	
	public function goNextStep(){
		$this->currentStep++;
	}
	
	public function goPrevious(){
		$this->currentStep--;
	}
	
	public function backToBeginning(){
		$this->currentStep = 1;
	}
}
?>
